/*
 * @Author: 秦福凯
 * @LastEditTime: 2025-05-22 09:23:29
 * @Description: 入口文件
 */
import { createApp } from 'vue';
import { createPinia } from 'pinia';
import * as ElementPlusIconsVue from '@element-plus/icons-vue';
import App from './App.vue';
import router from './router';
import  usePermissStore from './store/permiss';
import 'element-plus/dist/index.css';
import '@/assets/style/icon.css';
import '@/assets/style/index.scss';
import { parseTime, resetForm, addDateRange, handleTree, selectDictLabel, selectDictLabels } from '@/utils/tool'
import {useDict} from '@/utils/dict'

import 'element-plus/theme-chalk/dark/css-vars.css'//elementui+ 暗黑模式
import './assets/iconfont/iconfont.js'//引入阿里库icon 每次更新记得重新复制代码

//引入尺寸变化指令
import ResizeObserver from "v-resize-observer";

// pinia持续化插件
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
const pinia = createPinia()
pinia.use(piniaPluginPersistedstate)
import DataVVue3 from '@kjgl77/datav-vue3'//大屏可视化组件库


// video.js 插件
import 'video.js/dist/video-js.css';
const app = createApp(App);
app.use(ResizeObserver)

// 全局挂载
app.config.globalProperties.useDict = useDict;
app.config.globalProperties.parseTime = parseTime;
// app.config.globalProperties.resetForm = resetForm;
// app.config.globalProperties.handleTree = handleTree;
// app.config.globalProperties.addDateRange = addDateRange;
// app.config.globalProperties.selectDictLabel = selectDictLabel;
// app.config.globalProperties.selectDictLabels = selectDictLabels;

app.use(pinia);
app.use(router);
app.use(DataVVue3)//大屏可视化组件库

// 全局引入公共组件
import {componentPlugin } from  '@/components/common'
app.use(componentPlugin)


// 注册elementplus图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component);
}


// 自定义权限指令
app.directive('hasPermi', {
    mounted(el, binding) {
        if (binding.value && !usePermissStore().permissions.includes(String(binding.value))) {
            el['hidden'] = true;
        }
    },
});

app.mount('#app');
